|
|
|
|
|
|
|
'
' ignore indexes for foreign keys
If idxObject.Foreign = True Then
WrCreateIndex = ""
Exit Function
End If
'
' start SQL line
cTemp = "// Index " + idxObject.Name + EOL
If idxObject.Unique = True Then
cTemp = cTemp + "CREATE UNIQUE INDEX "
Else
cTemp = cTemp + "CREATE INDEX "
End If
'
' if name has spaces, add braces
cIndex = idxObject.Name
If InStr(cIndex, " ") <> 0 Then
cIndex = "[" + cIndex + "]"
End If
cTemp = cTemp + cIndex
'
' prepare to add fields
cTemp = cTemp + " ON " + cTable + EOL
cTemp = cTemp + Space(INDENT) + "("
'
' get each field in index
For Each fldObject In idxObject.Fields
cTemp = cTemp + fldObject.Name
If fldObject.Attributes = dbDescending Then
cTemp = cTemp + " DESC"
Else
cTemp = cTemp + " ASC"
End If
cTemp = cTemp + ","
Next
'
' fix up end of field list
If Right(cTemp, 1) = "," Then
cTemp = Left(cTemp, Len(cTemp) - 1)
End If
cTemp = cTemp + ")"
'
' handle index attributes
If idxObject.Primary = True Then
cTemp = cTemp + " WITH PRIMARY" ' primary key
End If
'
If idxObject.IgnoreNulls = True Then
cTemp = cTemp + " WITH IGNORE NULL" ' ignore nulls
End If
If idxObject.Required = True And idxObject.Primary = False Then
cTemp = cTemp + " WITH DISALLOW NULL" ' disallow nulls
End If
'
' last bit here! |
|
|
|
|
|